package com.wuyan.locationdog.adapter

import android.widget.ImageView
import android.widget.TextView
import androidx.annotation.LayoutRes
import com.arcsoft.commonbase.bean.GroupBeanContent
import com.arcsoft.commonbase.ext.gone
import com.arcsoft.commonbase.ext.visible
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.wuyan.locationdog.R


class GroupListAdapter(@LayoutRes layoutResId: Int, data: MutableList<GroupBeanContent>?) :
    BaseQuickAdapter<GroupBeanContent, BaseViewHolder>(layoutResId, data) {

    var showCheckBtn: Boolean = true

    override fun convert(holder: BaseViewHolder, item: GroupBeanContent) {
        holder.apply {

            getView<TextView>(R.id.deviceCount).text = item.deviceCount.toString()+"个设备"
            getView<TextView>(R.id.groupName).text = item.groupName
            val imageView = getView<ImageView>(R.id.ivCheck)

            if (showCheckBtn) {
                imageView.visible()
            } else {
                imageView.gone()
            }
            if (holder.adapterPosition==0) {
                imageView.gone()
            }

            if (item.isSelect) {
                imageView.setImageResource(R.mipmap.alarm_checked)
            } else {
                imageView.setImageResource(R.mipmap.alarm_unchecked)

            }
        }
    }
}


